package com.leetcode.q693;

/**
 * <p> description: desc</p>
 *
 * @author tanzc
 * @date 2022/3/30
 **/
public class HasAlternatingBits {
    public boolean hasAlternatingBits(int n) {
        int o = -1;
        while (n != 0) {
            if (n % 2 == o) {
                return false;
            }
            o = n % 2;
            n = n >> 1;
        }
        return true;
    }
}
